<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="./lib/react.development.js"></script>
    <script src="./lib/react-dom.development.js"></script>
    <script src="./lib/babel.min.js"></script>
    <style>
        *{
            padding:0;
            margin:0;
        }
        #root button{
            padding:5px;
            margin:5px;
        }
        #root button.active{
            background: red;
        }
        #root div{
            width: 500px;
            height: 300px;
            border:1px solid green;
        }
    </style>
</head>
<body>
<div id="root">

</div>

</body>
<script type="text/babel">
    const root = ReactDOM.createRoot(document.querySelector("#root"));
    class App extends React.Component{
        state = {
            activeIndex:1
        }
        changeActiveIndex(activeIndex){
            this.setState({activeIndex})
        }
        render(){
            return (
                <>
                    <button className={this.state.activeIndex===0?"active":""} onClick={this.changeActiveIndex.bind(this,0)}>娱乐</button>
                    <button className={this.state.activeIndex===1?"active":""} onClick={this.changeActiveIndex.bind(this,1)}>财经</button>
                    <button className={this.state.activeIndex===2?"active":""} onClick={this.changeActiveIndex.bind(this,2)}>体育</button>
                    <div style={{display:this.state.activeIndex===0?"block":"none"}}>娱乐新闻列表</div>
                    <div style={{display:this.state.activeIndex===1?"block":"none"}}>财经新闻列表</div>
                    <div style={{display:this.state.activeIndex===2?"block":"none"}}>体育新闻列表</div>
                </>
            )
        }
    }
    root.render(<App/>)
</script>
</html>